/**
 * 
 */
package com.impress.model;

import java.util.ArrayList;
import java.util.List;

/**
 * Label实体类
 * @author pluto
 * @version 1.0.1
 */
public class Label {

	private int _id;
	private String name;
	private String sortID;
	/**
	 * @return the _id
	 */
	public int get_id() {
		return _id;
	}
	/**
	 * @param _id the _id to set
	 */
	public void set_id(int _id) {
		this._id = _id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the sortID
	 */
	public String getSortID() {
		return sortID;
	}
	/**
	 * @param sortID the sortID to set
	 */
	public void setSortID(String sortID) {
		this.sortID = sortID;
	}
	
	
	public List<Feed> feeds = new ArrayList<Feed>();
	
//	public void SetFeeds(List<Feed> feeds){
//		this.feeds = feeds;
//	}
//	
//	public List<Feed> GetFeeds(){
//		return feeds;
//	}
	
	/**
	 * 标签的未读本地条目数
	 * @return
	 */
	public int GetUnreadCount(){
		int count = 0;
		for (Feed feed : feeds) {
			count += feed.GetUnreadCount();
		}
		return count;
	}
	
	/**
	 * 标签的所有本地条目数
	 * @return
	 */
	public int GetAllCount(){
		int count = 0;
		for (Feed feed : feeds) {
			count += feed.GetAllCount();
		}
		return count;
	}
	
	/**
	 * 标签只有一个含有未读条目的feed
	 * @return
	 */
	public boolean HasSingleFeed(){
		int count = 0;
		for (Feed feed : feeds) {
			if(count > 1){
				return false;
			}
			if (feed.GetUnreadCount()>0) {
				count++;
			}
		}
		return count == 1;
	}
	
	/**
	 * not implement yet.
	 */
	public void MarkAllRead(){
		//TODO mark all items in a label as read
	}
}
